package org.nViron.nvOrganic;

//~--- non-JDK imports --------------------------------------------------------

import org.nViron.nvData.nvDataEntity;
import org.nViron.nvData.nvDataEntitySimilarity;
import org.nViron.nvOrganism.nvOrganism;
import org.nViron.nvOrganism.nvStateMgr;
import org.nViron.nvParams.nvVizParamMgr.VIZPARAM;

/**
 * Base class for each component of an organic
 * @author Roland Haring <p>
 * <script type="text/javascript" src="http://www.ohloh.net/p/376434/widgets/project_basic_stats.js"></script>
 */
abstract public class nvTissue extends nvOrganism implements nvDataEntitySimilarity {
    private final nvOrganic organic;
    private final nvTissue  parent;
    private boolean   selected;

    public nvTissue(nvOrganic organic, nvTissue parent) {
        super(organic.getOrganicsMgr().getSimulator().getTissueMgr());
        this.organic = organic;
        selected     = false;
        this.parent  = parent;
    }

    abstract public void addEntity(nvDataEntity entity);

    @Override
    public void degenerate() {
        setState(nvStateMgr.DEGENERATING);
        onStateChange(getState());
    }

    abstract public int getNumEntities();

    public nvOrganic getOrganic() {
        return organic;
    }

    public nvTissue getParent() {
        return parent;
    }

    abstract public float getVizValue(VIZPARAM param);

    public boolean isSelected() {
        return selected;
    }

    abstract public boolean removeEntity(nvDataEntity entity);

    protected void setSelection(boolean b) {
        selected = b;
    }

    abstract public void updateVizValue(VIZPARAM param);
}



